package com.yyq.sos.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.yyq.adms.sysmanage.dao.SysParametersDao;
import com.yyq.adms.sysmanage.dao.impl.SysParametersDaoImpl;
import com.yyq.adms.sysmanage.pojo.SysParameters;
import com.yyq.servlets.ApplicationContextHandle;

/**
 * 系统参数实用类
 * @author Administrator
 */
public class SysParametersUtil 
{
	
	private static Map map = new HashMap();
	private final static SysParametersUtil instance = new SysParametersUtil();

	private SysParametersUtil()
	{
		
		SysParametersDao dao = (SysParametersDaoImpl)ApplicationContextHandle.getBean("sysParametersDao");
		List list = dao.list(SysParameters.class);
		for(int i=0; i<list.size(); ++i){
			SysParameters obj = (SysParameters)list.get(i);
			map.put(obj.getParameter(),obj.getValue());
		}
	}
	
	public static SysParametersUtil getInstance()
	{
		return instance;
	}
	
	public String getValue(String param)
	{
		return (String)map.get(param);
	}
	
	public void add(String param,String value){
		map.put(param, value);
	}
	
	public void delete(String param)
	{
		map.remove(param);
	}
}
